/**
 * Copyright &copy; 2012-2016 <a href="https://istep.lczyfz.com">Istep</a> All rights reserved.
 */
package com.lczyfz.istep.modules.resource.service;

import com.lczyfz.istep.common.persistence.Page;
import com.lczyfz.istep.common.service.CrudService;
import com.lczyfz.istep.modules.resource.dao.ResourceQuestionDao;
import com.lczyfz.istep.modules.resource.entity.ResourceQuestion;
import com.lczyfz.istep.modules.resource.entity.ResourceRepertory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 考题管理Service
 * @author dh
 * @version 2017-01-15
 */
@Service
@Transactional(readOnly = true)
public class ResourceQuestionService extends CrudService<ResourceQuestionDao, ResourceQuestion> {

	public ResourceQuestion get(String id) {
		return super.get(id);
	}

	public List<ResourceQuestion> findList(ResourceQuestion resourceQuestion) {
		return super.findList(resourceQuestion);
	}

	public Page<ResourceQuestion> findPage(Page<ResourceQuestion> page, ResourceQuestion resourceQuestion) {
		return super.findPage(page, resourceQuestion);
	}

//	根据题库id查询题目
    public Page<ResourceQuestion> findPageByRepertoryId(Page<ResourceQuestion> page, ResourceQuestion resourceQuestion) {
		resourceQuestion.setPage(page);
		page.setList(dao.findListByRepertoryId(resourceQuestion));
		return page;
	}

	//根据题库id来查询题目列表
	public List<ResourceQuestion> findListByRepertoryId(String repertoryId)
	{
		ResourceQuestion resourceQuestion =new ResourceQuestion();
		resourceQuestion.setRepertoryId(repertoryId);
		return dao.findListByRepertoryId(resourceQuestion);
	}

	//	根据试卷id查询题目
	public Page<ResourceQuestion> findPageByPaperId(Page<ResourceQuestion> page, ResourceQuestion resourceQuestion) {
		resourceQuestion.setPage(page);
		page.setList(dao.findListByPaperId(resourceQuestion));
		return page;
	}

//	public  ResourceQuestion findQuestionByRepertoryId(ResourceQuestion resourceQuestion)
//	{
//			return  dao.findListByRepertoryId(resourceQuestion);
//	}

	@Transactional(readOnly = false)
	public void save(ResourceQuestion resourceQuestion) {
		super.save(resourceQuestion);
	}

	@Transactional(readOnly = false)
	public void delete(ResourceQuestion resourceQuestion) {
		super.delete(resourceQuestion);
	}
	//	根据题目名称查询题目

	public ResourceQuestion findQuestionByName(ResourceQuestion resourceQuestion)
	{
		return dao.findQuestionByName(resourceQuestion);
	}

	public List<ResourceQuestion> fionQuestionReprtory(String repertoryId){
		return dao.fionQuestionReprtory(repertoryId);
	}
	public List<ResourceQuestion> fionQuestionType(String questionType){
		return  dao.fionQuestionType(questionType);
	}
}